<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>信息管理系统</title>
<base href="<?php echo base_url();?>public/admin/" />
<link rel="shortcut icon" href="favicon.ico" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="../plugins/jquery-ui/jquery-ui.min.css" rel="stylesheet" type="text/css" />
<script src="../plugins/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../plugins/jquery-ui/jquery-ui.min.js" type="text/javascript"></script>
<script src="../plugins/jquery.form.js" type="text/javascript"></script>
<script src="../plugins/jquery.idTabs.min.js" type="text/javascript"></script>
<script src="../plugins/template-native.js" type="text/javascript"></script>
<script src="../plugins/laypage/laypage.js" type="text/javascript"></script>
<script src="../plugins/ajaxfileuploader-2.1.js" type="text/javascript"></script>
</head>

<body style="background:url(images/left_bg.png) left repeat-y;">
<script src="../plugins/layer/layer.js" type="text/javascript"></script>
<div id="container">
  <div id="header">
    <div class="topleft">
    <a href="<?php echo site_url('index');?>"><img src="images/logo.png" title="系统首页" /></a>
    </div>
        
    <ul class="nav">
    <li><a href="<?php echo site_url('ui/news');?>#add" class="news_add"><img src="images/icon_news.png" title="添加新闻" /><h2>添加新闻</h2></a></li>
    <li><a href="<?php echo site_url('ui/product');?>#add" class="product_add"><img src="images/icon_pro.png" title="添加产品" /><h2>添加产品</h2></a></li>
    <li><a href="<?php echo site_url('ui/guestbook');?>"><img src="images/icon_msg.png" title="查看留言" /><h2>客户留言</h2></a></li>
    <li><a href="<?php echo site_url('ui/backup');?>"><img src="images/icon_backup.png" title="数据备份" /><h2>数据备份</h2></a></li>
    <li><a id="clear_cache"><img src="images/icon_clear.png" title="清除前台页面缓存" /><h2>清除缓存</h2></a></li>
    <li><a href="../../index.php" target="_blank"><img src="images/icon_home.png" title="浏览网站首页" /><h2>浏览网站</h2></a></li>
    </ul>
            
    <div class="topright">    
    <ul>
    <li><span><img src="images/help.png" title="帮助"  class="helpimg"/></span><a href="<?php echo site_url('ui/help');?>">帮助</a></li>
    <li><a href="<?php echo site_url('ui/about');?>">关于</a></li>
    <li><a id="btn_logout">退出</a></li>
    </ul>
     
    <div class="user">
    <span><?php  echo $user['username'];?></span>
    </div>    
    
    </div>
    
    <div class="clearfloat"></div>
  </div>
  <div id="mainContent">
    <div id="sidebar">
        <div class="lefttop"><span></span>管理菜单</div>        
        <dl class="leftmenu">            
        <?php if (!empty($menu)){ foreach ($menu[0] as $root){?>        
        <?php if(!empty($menu[$root['id']])){?>            
        <dd>
        <div class="title"><span><img src="<?php echo $root['icon'];?>" /></span><?php echo $root['name'];?><i class="clearfloat"></i></div>
            <ul class="menuson<?php echo isset($root['current'])?' current':'';?>">
                <?php foreach ($menu[$root['id']] as $sub){?>
                <li<?php echo isset($sub['active'])?' class="active"':'';?>><cite></cite><a href="<?php echo site_url($sub['uri']);?>" <?php echo $sub['target']?'target="_blank"':'';?>><?php echo $sub['name'];?></a><span class="clearfloat"></span><i></i></li>
                <?php }?>
            </ul>   
        </dd>
        <?php }?>
        <?php }}?>        
        </dl>
    </div>
    <div id="content">
        <div class="place">
            <span>当前位置：</span>
            <ul class="placeul">
            <?php if (!empty($menu)){  foreach ($location as $l){?>
            <?php if($l['url']){?>
                <li><a href="<?php echo site_url($l['url']);?>"><?php echo $l['title'];?></a></li>
            <?php }else{?>
                <li><?php echo $l['title'];?></li>
            <?php }?>
            <?php }}?>
            </ul>
            <div class="btn_op btn_add"><span><img src="images/t01.png"></span>添加</div>
            <div class="btn_op btn_back"><span><img src="images/t06.png"></span>列表</div>
        </div>
        <?php
            if(!empty($content_view))
            {
                $this->load->view($content_view);
            }
        ?>
    </div>
    <div class="clearfloat"></div>
  </div>
</div>
<div class="footer">
    <span>仅供学习交流，请勿用于任何商业用途</span>
    <i>版权所有 2016</i>    
</div>
<script type="text/javascript">
$(document).ready(function () {
    //菜单展开/折叠
    $('.title').click(function(){
        $('dd').find('ul').slideUp();
        var $ul = $(this).next('ul');        
        if($ul.is(':visible')){
        	$ul.slideUp();
        }else{
        	$ul.slideDown();
        }
    });
    
    /*
    //菜单栏高度
    $('.leftmenu').height($(document).height()-128);
    $(window).resize(function() { 
        $(".leftmenu").height($(document).height()-128);
    });
    */

    //退出登陆
    $('#btn_logout').click(function(){
        layer.confirm('确定退出？', {icon: 3, title:'提示', btn: ['是滴','点措了']}, function(){
            var url = '<?php echo site_url('ajax/user_handle/logout');?>';
            $.getJSON(url, {}, function(rs){
                if(rs.err===0){
                    location.href = '<?php echo site_url('ui/login');?>';            
                }else{
                    layer.msg(rs.msg, {icon:0,time:2000});
                }
              });
        });
        return false;
    });
    
    //清除缓存
    $('#clear_cache').click(function(){
        var url = '<?php echo site_url('ajax/cache_handle/clear');?>';
        $.getJSON(url, {}, function(rs){
            if(rs.err===0){
                layer.msg('清除成功！',{icon:1,time:2000});
            }else{
                layer.msg(rs.msg, {icon:0,time:2000});
            }
        });
        return false;
    });
})    
</script>
</body>
</html>